package [(${packageName})].controller;

import org.springframework.web.bind.annotation.*;
import [(${packageName})].service.I[(${className})]Service;
import [(${packageName})].entity.[(${className})]Entity;

/**
 * @author itpath.xyz
 * @date [(${time})]
 */
@RestController
@RequestMapping("/v1/[(${lowerClassName})]")
public class [(${className})]Controller {

    private final I[(${className})]Service [(${lowerClassName})]Service;

    public [(${className})]Controller(I[(${className})]Service [(${lowerClassName})]Service){
        this.[(${lowerClassName})]Service = [(${lowerClassName})]Service;
    }

    @PostMapping("/item/{id}")
    public Result<?> add[(${className})](@PathVariable Long [(${lowerClassName})]Id){
        [(${className})]Entity [(${lowerClassName})] = [(${lowerClassName})]Service.getById([(${lowerClassName})]Id);
        return ResultUtil.date([(${lowerClassName})]);
    }


    @PostMapping("/add")
    public Result<?> add[(${className})](@RequestBody [(${className})]Entity [(${lowerClassName})]){
        [(${lowerClassName})]Service.save([(${lowerClassName})]);
        return ResultUtil.ok("操作成功");
    }

    @PostMapping("/update")
    public Result<?> update[(${className})](@RequestBody [(${className})]Entity [(${lowerClassName})]){
        [(${lowerClassName})]Service.updateById([(${lowerClassName})]);
        return ResultUtil.ok("操作成功");
    }

    @DeleteMapping("/remove/{id}")
    public Result<?> remove[(${className})](@PathVariable Long [(${lowerClassName})]Id){
        [(${lowerClassName})]Service.removeById([(${lowerClassName})]Id);
        return ResultUtil.ok("操作成功");
    }

}